package com.apollo.test.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class FlowService {

    @SentinelResource(value = "com.apollo.test.service.FlowService:test",
            blockHandler = "testBlockHandler"
    )
    public String test() {
        log.info("正常执行");
        return "test";
    }

    public String testBlockHandler(BlockException e) {
        log.error("流控执行:", e);
        return "流控执行";
    }

}
